
#ifndef DIAGRAM_H_INCLUDED
#define DIAGRAM_H_INCLUDED

#include <d3dx9.h>
#include "Type.h"

struct SToolbarVertex
{
	float x, y, z, rhw;
	DWORD color;
	float tu, tv;
};

#define D3DFVF_TOOLBARVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)

//Handles 2D circuit diagram
class CDiagram
{
public:
	CDiagram();
	~CDiagram();

	bool init(HWND diagramHWND, LPDIRECT3DDEVICE9 pDevice, LPDIRECT3DSWAPCHAIN9 swapChain);
	bool render();
	void update();
	void cleanUp();

private:
	HWND                 hwnd;
	LPDIRECT3DDEVICE9    pD3DDevice;
	LPDIRECT3DSWAPCHAIN9 pSwapChain;
	LPD3DXFONT			 pFont;

	//Toolbar render objects
	LPDIRECT3DVERTEXBUFFER9 pToolbarVertexBuffer;
	LPDIRECT3DTEXTURE9      pResistorImage;
	LPDIRECT3DTEXTURE9      pBatteryImage;
	
	//Toolbar settings

	//Helper functions
	bool initToolbar();
	bool drawToolbar();
	bool drawText(LPCWSTR text, int x, int y, D3DCOLOR color, DWORD format = 0, int sx = 1000, int sy = 1000);
};

#endif
